#!/bin/bash
echo "安装将花费一定时间，请耐心等待直到安装完成"
if which apt-get >/dev/null; then
	sudo apt-get install -y vim vim-gnome ctags xclip astyle python-setuptools python-dev git
elif which yum >/dev/null; then
	sudo yum install -y gcc vim git ctags xclip astyle python-setuptools python-devel	
fi

##Add HomeBrew support on  Mac OS
if which brew >/dev/null;then
    echo "You are using HomeBrew tool"
    brew install vim ctags git astyle
fi

sudo easy_install -ZU autopep8 
sudo ln -s /usr/bin/ctags /usr/local/bin/ctags
mv -f ~/vim-configuration ~/vim-configuration_old
cd ~/ && git clone https://gitee.com/kokyu/vim-configuration.git
mv -f ~/.vim ~/.vim_old
mv -f ~/vim-configuration/.vim ~/
declare -a fonts=(
	JetBrainsMono
	NerdFontsSymbolsOnly
	ProFont
)

version='2.2.2'
fonts_dir="${HOME}/.local/share/fonts"

if [[ ! -d "$fonts_dir" ]]; then
    mkdir -p "$fonts_dir"
fi

for font in "${fonts[@]}"; do
    zip_file="${font}.zip"
    download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${zip_file}"
    echo "Downloading $download_url"
    wget "$download_url"
    unzip "$zip_file" -d "$fonts_dir" -x "*.txt/*" -x "*.md/*"
    rm "$zip_file"
done

find "$fonts_dir" -name '*Windows Compatible*' -delete

fc-cache -fv
mv -f ~/.vimrc ~/.vimrc_old
mv -f ~/vim-configuration/.vimrc ~/
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
echo "Halil正在安装Bundle程序" > Halil
echo "安装完毕将自动退出" >> Halil 
echo "请耐心等待" >> Halil
vim Halil -c "BundleInstall" -c "q" -c "q"
rm Halil
echo "安装完成"
